﻿
@{
    ViewBag.Title = "Grant roles";
}

<h2>Grant roles</h2>

<hr />

@Html.Partial("_Details")

<form id="form" class="form-horizontal" role="form" method="post">
    <div class="form-group">
        <label class="col-sm-2 control-label">Roles:</label>
        <div class="col-sm-10">
            <ul id="roles" class="list-group horizon">
                <li>
                    <div class="checkbox">
                        <label>
                            <input name="RoleId" type="checkbox" value="{{Id}}" />
                            {{Name}}
                        </label>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="form-group" style="margin-left:3px;margin-top:20px">
        <input class="col-sm-offset-2 btn btn-primary btn-sm" type="submit" value="Submit" />
        <input class="btn btn-info btn-sm" type="button" value="Return" onclick="javascript:history.go(-1)" />
    </div>
</form>

@section styles
{
    <style>
        .horizon > li {
            padding-right: 15px;
            list-style: none;
            float: left;
        }
    </style>
}

@section scripts
{
    <script>
        $(document).ready(function () {
            $.getJSON('/Data?name=user', {}, function (data, textStatus, jqXHR) {
                $('#details').renderer(data);
            });

            $.getJSON('/Data?name=allRoles', {}, function (data, textStatus, jqXHR) {
                $('#roles').renderer(data);
            }).done(function () {
                $.getJSON('/Data?name=roles', {}, function (data, textStatus, jqXHR) {
                    $('#form').deserializeObject(data);
                });
            });
        });
    </script>
}
